package com.lf.lexy.controller;

import java.io.IOException;
import java.util.List;

import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import com.jfinal.core.Controller;
import com.jfinal.kit.Base64Kit;
import com.jfinal.plugin.activerecord.Page;
import com.jfinal.plugin.activerecord.Record;
import com.lf.comm.MyConstants;
import com.lf.lexy.business.BlogBusiness;
import com.lf.lexy.dao.BlogContentDao;
import com.lf.lexy.model.BlogContent;
import com.lf.lexy.model.dto.Result;

public class BaseController extends Controller {
	
	
	private BlogBusiness blogBusiness = new BlogBusiness();

	public void index(){
		List<Record> blogTypeList = blogBusiness.getBlogTypeList("999999");
		setAttr("blogTypeList", blogTypeList);
		Page<BlogContent> blogContentList = blogBusiness.getBlogContentList("999999" , "" , "1" ,MyConstants.PAGE_SIZE_REC);
		setAttr("bloglist", blogContentList);
		setAttr("enFlag", MyConstants.ENFLAG);
//		render("rec_index.jsp");
		render("rec-index.jsp");
	}
	
	
	 public void success(Object object) {
    	MyConstants.log.info("=====>BaseController-返回数据:"+MyConstants.json.toJSONString(object));
        renderJson(new Result(MyConstants.CODE_SUCCESS, MyConstants.DESC_SUCCESS, object));
	 }

	 
	 public void render_base(){
		 render("/");
	 }
	 
	 
	 
	 public String getPar(String reqStr){
		 System.out.println(reqStr);
		 String par = null;
		 if(MyConstants.ENFLAG.equals("1")){
			 par = getPara(reqStr);
			 par = Base64Kit.decodeToStr(par);
		 }else{
			 par = getPara(reqStr);
		 }
		 
		 MyConstants.log.info("====>请求参数："+par);
		 return par;
	 }
	 
	
	
	
	
	
}
